import request from '@/utils/request'

export interface DefaultKeywordData {
  keyword: string
  schemeUrl: string | null
  highlight: number
  hidden: number
  type: number
  algSort: false
  extra: {
    resource?: {
      materialName: string
      resourcesId: number
      materialId: number
    }
    materialContentFrom?: number
    rcmdSort?: boolean
    taskType?: number
    alg_personalized?: string
    itemFrom?: number
    resourcesId?: number
  }
}

interface HotSearchListData {
  defaultKeyword: DefaultKeywordData
  defaultKeywords: DefaultKeywordData[]
  hotKeywordVOList: DefaultKeywordData[]
  colorfulEggList: []
}
export interface SearchTimeData {
  data: string[]
  code: string
}

interface HotSearchData {
  data: HotSearchListData
  code: string
}

export default {
  getHotSearch_search() {
    return request.get<any, HotSearchData>('/xhr/search/init.json')
  },
  getSearchTime_search(params: string) {
    return request.post<any, SearchTimeData>(
      `/xhr/search/searchAutoComplete.json?keywordPrefix=${params}`
    )
  },
  getSearchMainInfo(params:string) {
    return request.get<any,any>(
      `/xhr/search/search.json?__timestamp=1630133434953&needPopWindow=true&searchWordSource=7&stillSearch=false&_stat_search=autoComplete&itemId=0&size=40&upperPrice=-1&floorPrice=-1&matchType=0&categoryId=0&descSorted=false&sortType=0&keyword=${params}`
    )
  }
}
